from google.appengine.api import users

class Widget():
	pass
	
class LoginWidget(Widget):

	def __call__(self, request):
		user = users.get_current_user()

		if user:
			logout_url = users.create_logout_url(request.uri)
			header_html = '<p>You are currently logged in as %s | <a href="%s">Sign out</a></p>' % (user.nickname(), logout_url)
		else:
			login_url = users.create_login_url(request.uri)
			header_html = '<p><a href="%s">Sign in</a></p>' % (login_url)
			
		return header_html